/*
 * Copyright (C), 2014-2016, org.esaydev
 * FileName: BaseMsg.java
 * Author:   jian
 * Date:     2016年3月24日 
 */
package org.easydev.wechat.message.base;

import org.easydev.wechat.common.util.XmlBuilder;

import com.thoughtworks.xstream.annotations.XStreamAlias;

/**
 * <Description> 微信消息基础定义<br>
 * 
 * @author jian<br>
 */
public class BaseMsg {

    /**
     * 开发者微信号
     */
    @XStreamAlias("ToUserName")
    private String toUserName;

    /**
     * 发送方帐号（一个OpenID）
     */
    @XStreamAlias("FromUserName")
    private String fromUserName;

    /**
     * 消息创建时间 （整型）
     */
    @XStreamAlias("CreateTime")
    private String createTime;

    /**
     * 消息类型
     */
    @XStreamAlias("MsgType")
    private String msgType;

    /**
     * get toUserName
     * 
     * @return Returns the toUserName.<br>
     */
    public String getToUserName() {
        return toUserName;
    }

    /**
     * set toUserName
     * 
     * @param toUserName The toUserName to set. <br>
     */
    public void setToUserName(String toUserName) {
        this.toUserName = toUserName;
    }

    /**
     * get fromUserName
     * 
     * @return Returns the fromUserName.<br>
     */
    public String getFromUserName() {
        return fromUserName;
    }

    /**
     * set fromUserName
     * 
     * @param fromUserName The fromUserName to set. <br>
     */
    public void setFromUserName(String fromUserName) {
        this.fromUserName = fromUserName;
    }

    /**
     * get createTime
     * 
     * @return Returns the createTime.<br>
     */
    public String getCreateTime() {
        return createTime;
    }

    /**
     * set createTime
     * 
     * @param createTime The createTime to set. <br>
     */
    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    /**
     * get msgType
     * 
     * @return Returns the msgType.<br>
     */
    public String getMsgType() {
        return msgType;
    }

    /**
     * set msgType
     * 
     * @param msgType The msgType to set. <br>
     */
    public void setMsgType(String msgType) {
        this.msgType = msgType;
    }

    public String toString() {
        // 159 = 106 + 28(ToUserName) + 15(FromUserName) + 10(CreateTime)
        XmlBuilder builder = new XmlBuilder(159);
        builder.addData("ToUserName", getToUserName());
        builder.addData("FromUserName", getFromUserName());
        builder.addTag("CreateTime", String.valueOf(System.currentTimeMillis()).substring(0, 10));
        return builder.toString();
    }
}
